package com.lsj.config.oauth2;

import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.stereotype.Component;

import java.util.Map;

/*自定义的CustomEnhancer，可以实现在返回的access_token和refresh_token中加入自定义的信息*/
@Component
public class CustomEnhancer implements TokenEnhancer {

    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken oAuth2AccessToken, OAuth2Authentication oAuth2Authentication) {
        Map<String, Object> info= oAuth2AccessToken.getAdditionalInformation();
        info.put("author","林世杰");
        return oAuth2AccessToken;
    }
}
